package com.golden.zip.module;

import javax.servlet.http.HttpSession;

import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Fail;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.mvc.view.JspView;

@IocBean
@At("/main")
@Ok("json")
@Fail("http:500")
public class LoginModule {

    @At
    @Ok(">>:/main/zipList")
    public Object login(@Param("userName")String userName, @Param("password")String password, HttpSession session) {
        if ("admin".equals(userName) && "123456".equals(password)) {
            session.setAttribute("userName","admin");
            return true;
        } else {
            session.setAttribute("message","用户名或密码错误");
            return new JspView("pages.message");
        }
    }
    
    @At
    @Ok(">>:/main/zipList")
    public void logout(HttpSession session) {
        session.invalidate();
    }
    
    @At
    @Ok("jsp:pages/login")
    public void index(){
    }
}
